<template>
  <div class="dashboard-container">
    <div class="app-container">
      <el-row type="flex" justify="space-between" :gutter="30">
        <el-col :span="12">
          <div class="left-box">左盒子</div>
        </el-col>
        <el-col :span="12">
          <div class="rigth-box">右盒子</div>
        </el-col>
      </el-row>
    </div>
  </div>
</template>

<script>
import { mapGetters } from 'vuex'
import * as echarts from 'echarts'
export default {
  name: 'Dashboard',
  computed: {
    ...mapGetters([
      'name'
    ])
  },
  mounted() {
    this.setLeftEcharts()
    this.setRigthEcharts()
  },
  methods: {
    // 左边
    setLeftEcharts() {
      const myChart = echarts.init(document.querySelector('.left-box'))
      const option = {
        title: {
          text: '价格数量分布'
        },
        legend: {},
        tooltip: {},
        dataset: {
          source: [
            ['product', '公寓', '别墅', '商业'],
            ['Matcha Latte', 43.3, 85.8, 93.7],
            ['Milk Tea', 83.1, 73.4, 55.1],
            ['Cheese Cocoa', 86.4, 65.2, 82.5],
            ['Walnut Brownie', 72.4, 53.9, 39.1]
          ]
        },
        xAxis: { type: 'category' },
        yAxis: {},
        // Declare several bar series, each will be mapped
        // to a column of dataset.source by default.
        series: [{ type: 'bar' }, { type: 'bar' }, { type: 'bar' }]
      }
      option && myChart.setOption(option)
    },
    // 右边
    setRigthEcharts() {
      const myChart = echarts.init(document.querySelector('.rigth-box'))
      const option = {
        tooltip: {
          formatter: '{a} <br/>{b} : {c}%'
        },
        series: [
          {
            name: 'Pressure',
            type: 'gauge',
            progress: {
              show: true
            },
            detail: {
              valueAnimation: true,
              formatter: '{value}'
            },
            data: [
              {
                value: 70,
                name: 'SCORE'
              }
            ]
          }
        ]
      }
      option && myChart.setOption(option)
    }
  }
}
</script>

<style lang="scss" scoped>
.dashboard {
  &-container {
    margin: 30px;
  }
  &-text {
    font-size: 30px;
    line-height: 46px;
  }
}
.left-box,
  .rigth-box{
    height: 600px;
    border: 1px solid #000;
  }
</style>
